package com.qys.livesMall.shop.service.impl;

import com.qys.livesMall.common.exception.QysException;
import com.qys.livesMall.common.utils.MessageUtils;
import com.qys.livesMall.framework.utils.SecurityUtils;
import com.qys.livesMall.shop.modal.entity.ShopOrderReturnProcess;
import com.qys.livesMall.shop.mapper.ShopOrderReturnProcessMapper;
import com.qys.livesMall.shop.service.ShopOrderReturnProcessService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author gmx
 * @since 2023-06-25
 */
@Service
public class ShopOrderReturnProcessServiceImpl extends ServiceImpl<ShopOrderReturnProcessMapper, ShopOrderReturnProcess> implements ShopOrderReturnProcessService {

    @Override
    public void add(Long approvredId, Integer status,Integer type) {
        add( approvredId,  status,null,type);
    }

    @Override
    public void add(Long approvredId, Integer status,String opinion,Integer type) {
        ShopOrderReturnProcess process = new ShopOrderReturnProcess();
        process.setProcessUser("1");
        process.setApprovedId(approvredId);
        process.setStatus(status);
        process.setUserId(SecurityUtils.getUserId());
        process.setUserName(SecurityUtils.getUsername());
        process.setOpinion(opinion);
        process.setCreateTime(LocalDateTime.now());
        process.setUpdateTime(LocalDateTime.now());
        process.setType(type);
        if (!save(process)) throw new QysException(MessageUtils.message("system.error.process"));
    }
}
